package view
{
	import flash.display.Graphics;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	
	/**
	 * ...
	 * @author bimkute
	 */
	public class LoginScreen extends Base
	{
		public var _userName:String = "test2";
		private var inputField:TextField;
		private var sprite:Sprite;
		
		public function LoginScreen()
		{
			addEventListener(Event.ADDED_TO_STAGE, onAddToStage);
		
		}
		
		private function onAddToStage(e:Event):void
		{
			removeEventListener(Event.ADDED_TO_STAGE, onAddToStage);
			
			var container:Sprite = new Sprite();
			container.graphics.beginFill(0x00CCFF, .5);
			container.graphics.lineStyle(1, 0x00CCFF);
			container.graphics.drawRect(0, 0, 1400, 900);
			container.graphics.endFill()
			addChild(container);
			
			inputField = new TextField();
			
			addChild(inputField);
			
			inputField.border = true;
			inputField.width = 200;
			inputField.height = 150;
			inputField.x = 575;
			inputField.y = 550;
			
			inputField.type = "input";
			
			stage.focus = inputField;
			
			inputField.maxChars = 20;
			
			inputField.restrict = "A-Za-z0-9";
			
			inputField.text = "test2";
			
			inputField.addEventListener(Event.CHANGE, onChange);
			
			sprite = new Sprite();
			var g:Graphics = sprite.graphics;
			
			g.beginFill(0, 1);
			g.drawRect(0, 0, 100, 50);
			
			g.endFill();
			addChild(sprite);
			sprite.x = 400;
			sprite.y = 400;
			
			sprite.addEventListener(MouseEvent.CLICK, onClick);
		
		
		}
		
		private function onClick(e:MouseEvent):void 
		{
			dispatchEvent(new Event("login"));
		}
		
		private function onChange(e:Event):void
		{
			var inputField:TextField = e.currentTarget as TextField;
			
			_userName = inputField.text;
		}
		
		public function removeAllEvent():void 
		{
			sprite.removeEventListener(MouseEvent.CLICK, onClick);
			inputField.removeEventListener(Event.CHANGE, onChange);
		}
	
	}

}